<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>红包列表</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {include file="public/css"/}
	<style>
	#urlqr img{margin:0 auto}
	</style>
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-card layui-col-md12">
          <div class="layui-card-header">
			 <i class="fa fa-list"></i>红包列表 {if input('param.isopen')==1}<i class="layui-icon layui-icon-close" style="font-size:18px;font-weight:bold;cursor:pointer" onclick="closeself()"></i>{/if}
		  </div>
		  <div class="layu`i-card-body" pad15>
			<div class="layui-col-md6" style="padding-bottom:10px">
			</div>
			<div class="layui-form layui-col-md6 layui-form-search">
				<div class="layui-inline layuiadmin-input-useradmin">
					<label class="layui-form-label">订单号</label>
					<div class="layui-input-inline">
						<input type="text" name="ordernum" autocomplete="off" class="layui-input" value="">
					</div>
				</div>
				<div class="layui-inline">
					<button class="layui-btn layuiadmin-btn-replys" lay-submit="" lay-filter="LAY-app-forumreply-search">
						<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
					</button>
				</div>
			</div>
			<div class="layui-col-md12">
				<table id="tabledata" lay-filter="tabledata"></table>
			</div>
          </div>
        </div>
    </div>
  </div>
	{include file="public/js"/}
	<script>
	layui.laydate.render({ 
		elem: '#ctime',
		trigger: 'click',
		range: '~' //或 range: '~' 来自定义分割字符
	});
  var table = layui.table;
	var datawhere = {};
  //数据表
  var tableIns = table.render({
    elem: '#tabledata'
    ,url: "{$Request.url}" //数据接口
    ,page: true //开启分页
    ,cols: [[ //表头
			{type:"checkbox"},
      {field: 'id', title: 'ID',width:80},
		  {field: 'ordernum', title: '订单号',width:180},
      {field: 'openid', title: 'Openid'},
      {field: 'money', title: '金额',width:100},
      {field: 'appid', title: 'Appid',width:180},
      {field: 'mchid', title: '商户号',width:180},
      {field: 'createtime', title: '发放时间',width:180},
      {field: 'status', title: '状态',templet:function(d){ 
				if(d.status==1){
					return '<span style="color:green">成功</span>';
				}else{
					return '<span style="color:red">失败</span>';
				}
			},width:100},
	  {field: 'remark', title: '备注',width:200},
      {field: 'operation', title: '操作',width:200,templet:function(d){
				var html = '';
				html += '<button class="table-btn" onclick="getinfo('+d.id+')">查询</button>';
				return html;
			}}
    ]]
  });
	//排序
	table.on('sort(tabledata)', function(obj){
		datawhere.field = obj.field;
		datawhere.order = obj.type;
		tableIns.reload({
			initSort: obj,
			where: datawhere
		});
	});
	//检索
	layui.form.on('submit(LAY-app-forumreply-search)', function(obj){
		var field = obj.field
		var olddatawhere = datawhere
		datawhere = field
		datawhere.field = olddatawhere.field
		datawhere.order = olddatawhere.order
		tableIns.reload({
			where: datawhere,
			page: {curr: 1}
		});
	});
	//删除
	function getinfo(id){
		var index = layer.load();
		$.post("{:url('redpackinfo')}",{id:id},function(res){
			layer.close(index);
			var html = '';
			html+='	<div class="layui-form-item" style="margin-top:40px;margin-right:20px;">';
			html+='		<label class="layui-form-label" style="width:80px">状态</label>';
			html+='		<div class="layui-input-inline" style="width:350px">';
			html+=res.data.status;
			html+='		</div>';
			html+='	</div>';
			var infoLayer = layer.open({type:1,area:['500px','250px'],title:false,content:html,shadeClose:true,btn: ['确定', '取消'],
				yes:function(){
					layer.close(infoLayer);
				}
			});
		})
	}
	</script>
	{include file="public/copyright"/}
	<div id="NewsToolBox"></div>
</body>
</html>